#include "cclientdata.h"
#include <QDebug>

CClientData::CClientData()
{
    m_pMutex = new QMutex();
	m_nPort = 0;
	m_bState = false;
	m_bAlarm = false;
	m_dCPU = 0.0;
	m_dMemory = 0.0;
	m_nPointCount = 0;
    m_nCRCType = 0;
    m_nCRC = 0;
    m_bTagsReadReady = false;
	m_vecTag.clear();
	m_mapTag.clear();
    m_bEnabled = false;
}

CClientData::~CClientData()
{
	if (m_pMutex)
	{
		delete m_pMutex;
		m_pMutex = nullptr;
    }
}

void CClientData::clearTags()
{
    for (int i = 0; i < m_vecTag.size(); i++)
    {
        CTagData* pTag = m_vecTag.at(i);
        delete pTag;
        pTag = nullptr;
    }
    m_vecTag.clear();
    m_mapTag.clear();
    m_nPointCount = 0;
    m_nCRC = 0;
}

int CClientData::getPointCount()
{
    m_nPointCount = m_vecTag.size();
    return m_nPointCount;
}

void CClientData::slotClientStatusChanged(QString sGuid, bool bState)
{
    if (m_sGuid != sGuid || true == sGuid.isEmpty()) return;
    qDebug() << "Current guid:" << m_sGuid << "Recv:" << sGuid << bState;
    m_bState = bState;
}
